<?php $path = Yii::app()->request->baseUrl . '/'; ?>
<div style="clear:both;">
    <div style="position: relative;float:left;width: 50%;">
        <h2><font style="color: #0066A4;">QUẢN LÝ THIẾT BỊ</font></h2>
    </div>
    <div style="position: relative;float:right;width: 25%;padding-top: 10px;">
        <link href="<?php echo $path ?>css/search.css" rel="stylesheet" type="text/css" />
        <a id="show_hide" href="javascript:void(0)" onclick="jQuery('#_section').toggle();">
            <?php echo CHtml::image($path . 'css/img/search.png', 'Search', array('width' => 23, 'height' => 20)); ?>
        </a>
        <div id ="_section" style="display:none; padding:5px 10px 0; background-color:#EEE; z-index: 1; position:absolute; border:#AFD0F5 1px; border-style:ridge;">
            <style type="text/css">
                div.form .row {
                    margin: 5px 0;
                    margin-bottom: 0px;
                }
            </style>
            <div class="form">
                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id' => 'search-form',
                    'action' => array('search'),
                    'enableAjaxValidation' => true,
                    'htmlOptions' => array('accept-charset' => 'UTF-8'), //, 'accept-charset' => 'UTF-8'
                        ));
                ?>
                <?php
                echo $form->errorSummary($productSearch);
                ?>
                <div>
                    <?php echo $form->textField($productSearch, 'keyWord', array('size' => 30, 'maxlength' => 100, 'placeholder' => 'Nhập vào từ khóa')); ?>
                    <?php echo $form->error($productSearch, 'keyWord'); ?>
                </div>

                <div>
                    <?php echo $form->checkBox($productSearch, 'searchByName', array('value' => true, 'uncheckValue' => false)) . ' Tìm theo tên'; ?>
                    <?php echo $form->error($productSearch, 'searchByName'); ?>
                </div>

                <div>
                    <?php echo $form->checkBox($productSearch, 'searchByContent', array('value' => true, 'uncheckValue' => false)) . ' Tìm theo nội dung'; ?>
                    <?php echo $form->error($productSearch, 'searchByContent'); ?>
                </div>

                <div class="row buttons">
                    <?php
                    echo CHtml::submitButton(Yii::t('product', 'search'), array('width' => 20));
                    ?>
                </div>
                <?php $this->endWidget(); ?>
            </div>   
        </div>
    </div>
</div>
<div style="clear:both;">
    <?php if (Yii::app()->user->hasFlash('message')): ?>
        <div class="flash-notice">
            <?php echo Yii::app()->user->getFlash('message'); ?>
        </div>
    <?php endif; ?>
    <?php
    $this->widget('zii.widgets.grid.CGridView', array(
        'id' => 'product-grid',
        'dataProvider' => $dataProvider,
        //'filter' => ,
        'ajaxUpdate' => false,
        'pager' => array(
            //'cssFile'=>false,
            'class' => 'CLinkPager',
            'header' => '',
            'maxButtonCount' => 10,
            'pageSize' => 15,
            'firstPageLabel' => '<<',
            'prevPageLabel' => 'Prev',
            'nextPageLabel' => 'Next',
            'lastPageLabel' => '>>',
        ),
        'columns' => array(
            array(
                'name' => 'Danh mục',
                'value' => '$data->getCategoryName()',
            ),
            array(
                'name' => 'Tên tiếng Việt',
                'value' => '$data->getProductDetail("vi")->name',
            ),
            array(
                'name' => 'Tên tiếng Anh',
                'value' => '$data->getProductDetail("en")->name',
            ),
            array(
                'name' => 'Mã code',
                'value' => '$data->code',
            ),
            array(
                'name' => 'Nội dung',
                'type' => 'raw',
                'value' => 'CHtml::ajaxLink(\'Xem\', array(\'product/content\',\'id\'=>$data->id), array(
                \'onclick\' => \'$(\"#showDialog\").dialog(\"open\"); return false;\',
                \'update\' => \'#showDialog\'))',
            ),
            array(
                'name' => 'Hình ảnh',
                'type' => 'raw',
                'value' => 'CHtml::ajaxLink(\'Xem\', array(\'product/images\',\'id\'=>$data->id), array(
                \'onclick\' => \'$(\"#showDialog\").dialog(\"open\"); return false;\',
                \'update\' => \'#showDialog\'))',
            ),
            array(
                'class' => 'CButtonColumn',
                'template' => '{update}{delete}',
            /* 'buttons' => array
              (
              'update' => array(
              'label' => 'Update category',
              'imageUrl' => Yii::app()->request->baseUrl . '/images/layout/update.png',
              ),
              'delete' => array(
              'label' => 'Delete category',
              'imageUrl' => Yii::app()->request->baseUrl . '/images/layout/delete.png',
              ),
              ), */
            //'htmlOptions' => array('width' => '60'),
            ),
        ),
    ));
    ?>
    <div id="showDialog"></div>
</div>
